
////////浏览器视口的高度
   function windowHeight() {
       var myHeight = 0;
       if (typeof(window.innerHeight) == 'number') {
           //Non-IE
           myHeight = window.innerHeight;
       } else if (document.documentElement && (document.documentElement.clientHeight)) {
           //IE 6+ in 'standards compliant mode'
           myHeight = document.documentElement.clientHeight;
       } else if (document.body && (document.body.clientHeight)) {
           //IE 4 compatible
           myHeight = document.body.clientHeight;
       }
       return myHeight;
   }
   
/* 登录窗口 */
function showLogin(){
    var mini_login = document.getElementById("mini_login");
    var cover = document.getElementById("cover");
    var tip_show = document.getElementById("tip_show");
    mini_login.style.display = "block";
    cover.style.display = "block";
    tip_show.style.display = "none";
    var bodyHeight = windowHeight();
    mini_login.style.left = (document.body.scrollWidth - mini_login.scrollWidth) / 2 + "px";
    mini_login.style.top = (bodyHeight - mini_login.scrollHeight - 100) / 2 + "px";
}
function closeLogin(){
    var mini_login = document.getElementById("mini_login");
    var cover = document.getElementById("cover");
    mini_login.style.display = "none";
    cover.style.display = "none";
}
function clickLogin(){
    var form = document.getElementById("form_login");
    var tip_show = document.getElementById("tip_show");
    
    if( form.uname.value.length == 0 ){
        return;
    }
    else if( form.upwd.value.length == 0 ){
        tip_show.style.display = "block";
        document.getElementById("error_desc").innerHTML = "你还没有输入密码！";
        form.upwd.focus();
    }
    else{
        var xmlHttp = false;
        if(window.XMLHttpRequest){ // code for IE7+, Firefox, Chrome, Opera, Safari
    		xmlHttp = new XMLHttpRequest();
    	}
    	else{	// code for IE6, IE5
    		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    	}
        
        var url = "pay/query_user.php";
        var data = "check=1&uname="+form.uname.value+"&upwd="+form.upwd.value;
        xmlHttp.open("POST", encodeURI(url), true);
        xmlHttp.onreadystatechange = function updatePage() {//服务器返回值的处理函数，此处使用匿名函数进行实现;
            if( xmlHttp.readyState != 4 )   // 4代表请求服务器响应完成
                return;
            var response = xmlHttp.responseText;
            if( response == "success" ){
                window.location.reload();    
            }
            else{
                tip_show.style.display = "block";
                document.getElementById("error_desc").innerHTML = "你输入的账号或密码不正确！";
                form.upwd.focus();
            }
        };
        xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        xmlHttp.send(data);
    }
}

var qcode_fee = 198;
var qcode_src = "pay/alipay/alipayapi.php";

/* 支付窗口 */
function showPay(name){
    var mini_pay = document.getElementById("mini_pay");
    var cover = document.getElementById("cover");
    mini_pay.style.display = "block";
    cover.style.display = "block";
    var bodyHeight = windowHeight();
    mini_pay.style.left = (document.body.scrollWidth - mini_pay.scrollWidth) / 2 + "px";
    mini_pay.style.top = (bodyHeight - mini_pay.scrollHeight) / 2 + "px";
    
    var url = "";
    $('#iframe_qcode').attr("src",url);
}
function closePay(tid){
    if( tid == 1 ){
        var mini_pay = document.getElementById("mini_pay");
        mini_pay.style.display = "none";
    }
    else if( tid == 2 ){
        var mini_res = document.getElementById("mini_result");
        mini_res.style.display = "none";
    }
    var cover = document.getElementById("cover");
    cover.style.display = "none";
}

/* 支付窗口 */
function showResult(){
    var mini_res = document.getElementById("mini_result");
    var cover = document.getElementById("cover");
    mini_res.style.display = "block";
    cover.style.display = "block";
    var bodyHeight=(document.body.scrollHeight > mini_res.scrollHeight) ? document.body.scrollHeight : document.documentElement.scrollHeight;
    mini_res.style.left = (document.body.scrollWidth - mini_res.scrollWidth) / 2 + "px";
    mini_res.style.top = (bodyHeight - mini_res.scrollHeight) / 2 + "px";
}

function submitBankPay(){
    var form = document.getElementById("form_bank_pay");
    form.submit();
}

/* 支付窗口中选择时长和支付方式 */
$(function(){
    
    var timeSel = $('.paytime');
    timeSel.on('click','li',function(){
        timeSel.find('li').removeClass('active');
        $(this).addClass('active');
        
        var fee = $(this).val();
        //var url = $('#iframe_qcode')[0].src;
        var url = "";
        var pos = url.lastIndexOf("kkfee=");
        var url2 = url.substring(0,pos) + "kkfee=" + fee;
        $('#iframe_qcode').attr("src",url2);
        $('#bank_fee').val(fee);
        
        qcode_fee = fee;
    });
    
    var typeSel = $('.paytype');
    typeSel.on('click','li',function(){
        typeSel.find('li').removeClass('active');
        $(this).addClass('active');
        
        var type = $(this).val();
        if( type == 201 ){
            $('.bank_pay').css("display","none");
            $('.qcode').css("display","block");
            $('#qcode_tip').html('请使用支付宝扫码支付');
            $('#iframe_qcode').attr("class","qcode_ali");
            qcode_src = "pay/alipay/alipayapi.php";
            //var url = $('#iframe_qcode')[0].src;
            var url = "";
            var pos = url.indexOf("?");
            var url2 = "pay/alipay/alipayapi.php" + url.substring(pos,url.length);
            $('#iframe_qcode').attr("src",url2);
        }
        else if( type == 202 ){
            $('.bank_pay').css("display","none");
            $('.qcode').css("display","block");
            $('#qcode_tip').html('请使用微信扫码支付');
            $('#iframe_qcode').attr("class","qcode_wx");
            qcode_src = "pay/weixin/example/native.php";
            var url = $('#iframe_qcode')[0].src;
            var pos = url.indexOf("?");
            var url2 = "pay/weixin/example/native.php" + url.substring(pos,url.length);
            $('#iframe_qcode').attr("src",url2);
        }
        else if( type == 203 ){
            $('.qcode').css("display","none");
            $('.bank_pay').css("display","block");
        }
    });
 })


 


